package com.test.springCloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.client.RestTemplate;

/**
 * 用于发现服务
 */
@Configuration
public class SpringCloudDemoConfigBean {


    /**
     * 负载均衡
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate loadBalanced(){

        return new RestTemplate();
    }

    /**
     * 默认优先选择
     * @return
     */
    @Primary
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
